package com.hmall.api.client;

import com.hmall.api.client.fallback.ItemFallbackFactory;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

@FeignClient(value = "item-service",path = "/items", fallbackFactory = ItemFallbackFactory.class)
public interface ItemClient {


    @GetMapping
    public List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);


    @PutMapping("/stock/deduct")
    public void deductStock(@RequestBody List<OrderDetailDTO> items);
    // 请求路径  请求方式  请求参数 相应结果

    @ApiOperation("分页查询商品,给search微服务提供的")
    @GetMapping("/pageList")
    public List<ItemDTO> queryItemByPage(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize")Integer pageSize);
}
